package name.matthewgreet.example9.action; import org.apache.struts2.ActionSupport; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.InterceptorRef; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import name.matthewgreet.example9.form.DateOfBirthDefaultConversionForm; import name.matthewgreet.example9.form.FlagDefaultConversionForm; import name.matthewgreet.example9.form.RatingDefaultConversionForm; import name.matthewgreet.example9.form.RequiredScoreDefaultConversionForm; import name.matthewgreet.example9.form.TechAttitudeDefaultConversionForm; import name.matthewgreet.example9.view.AttitudeSelectBoxDisplay; import name.matthewgreet.example9.view.RatingSelectBoxDisplay; import name.matthewgreet.example9.view.TechCompanySelectBoxDisplay; import name.matthewgreet.strutscommons.action.AbstractViewActionSupport; /** * Displays tests of parameter converted directly to non-string, unformatted fields using the default converter. */ @InterceptorRef("ViewStack") @Results({ @Result(name=ActionSupport.SUCCESS, location="/pages/DefaultConversions.jsp") }) public class ViewDefaultConversionsAction extends AbstractViewActionSupport { private static final long serialVersionUID = -7979376337555804889L; private RequiredScoreDefaultConversionForm requiredScoreForm; private FlagDefaultConversionForm flagForm; private RatingDefaultConversionForm ratingForm; private DateOfBirthDefaultConversionForm dateOfBirthForm; private TechAttitudeDefaultConversionForm techAttitudeForm; private RatingSelectBoxDisplay ratingSelectBoxDisplay; private TechCompanySelectBoxDisplay techCompanySelectBoxDisplay; private AttitudeSelectBoxDisplay attitudeSelectBoxDisplay; @Action("/ViewDefaultConversion") @Override public String execute() throws Exception { if (requiredScoreForm == null) { requiredScoreForm = new RequiredScoreDefaultConversionForm(); } if (flagForm == null) { flagForm = new FlagDefaultConversionForm(); } if (dateOfBirthForm == null) { dateOfBirthForm = new DateOfBirthDefaultConversionForm(); } if (ratingForm == null) { ratingForm = new RatingDefaultConversionForm(); } if (techAttitudeForm == null) { techAttitudeForm = new TechAttitudeDefaultConversionForm(); } ratingSelectBoxDisplay = new RatingSelectBoxDisplay(); ratingSelectBoxDisplay.setSelectedValue(ratingForm.getRating()); techCompanySelectBoxDisplay = new TechCompanySelectBoxDisplay(); techCompanySelectBoxDisplay.setSelectedValue(techAttitudeForm.getTechCompany()); attitudeSelectBoxDisplay = new AttitudeSelectBoxDisplay(); attitudeSelectBoxDisplay.setSelectedValue(techAttitudeForm.getAttitude()); return SUCCESS; } public RequiredScoreDefaultConversionForm getRequiredScoreForm() { return requiredScoreForm; } public FlagDefaultConversionForm getFlagForm() { return flagForm; } public DateOfBirthDefaultConversionForm getDateOfBirthForm() { return dateOfBirthForm; } public TechAttitudeDefaultConversionForm getTechAttitudeForm() { return techAttitudeForm; } public RatingDefaultConversionForm getRatingForm() { return ratingForm; } public RatingSelectBoxDisplay getRatingSelectBoxDisplay() { return ratingSelectBoxDisplay; } public TechCompanySelectBoxDisplay getTechCompanySelectBoxDisplay() { return techCompanySelectBoxDisplay; } public AttitudeSelectBoxDisplay getAttitudeSelectBoxDisplay() { return attitudeSelectBoxDisplay; } }